//户籍迁出操作按钮
function onHjqcSuoActionRenderer(e) {
    var record1 = e.value;
    var arr = record1.split("@");
    var level = arr[0];
    var record = arr[1];
    var s = "";
    //司法所
    if (level == '3') {
        if (record == "1") {
            s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toRevoke(0)"  >&nbsp;&nbsp;撤回&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "0") {
            s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toEditOutRevoke()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "3") {//迁出审批失败查看
            s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toEditOutRevoke()"  >&nbsp;&nbsp;重新申请&nbsp;&nbsp;</a>&nbsp';
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqc()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "7") {//迁入审批失败查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "2") {//迁出审批通过查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "6") {//迁入审批通过查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        }
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    } else if (level == '8') { //区县司法局
        if (record == "1") {
            s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toOutShenhe()"  >&nbsp;&nbsp;迁出审核&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "3") {//迁出审批失败查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqc()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "7") {//迁入审批失败查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "2") {//迁出审批通过查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        } else if (record == "6") {//迁入审批通过查看
            s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
        }
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    } else if (level == '6' || level == '7') {
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    }
}

//户籍迁入--司法所申请
function onHjqrSuoActionRenderer(e) {
    var record1 = e.value;
    var arr = record1.split("@");
    var level = arr[0];
    var record = arr[1];
    var localCode = arr[2];
    var s = "";
    if (level == '3') {
        // 山西个性化需求
        if(localCode == "140000") {
            if(record=="6"){
                s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toAccept()">&nbsp;&nbsp;接收&nbsp;&nbsp;</a>&nbsp';
            } else if(record=="5"){
                s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toRevoke(4)">&nbsp;&nbsp;撤回&nbsp;&nbsp;</a>&nbsp';
            } else if(record=="4"){
                s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toEditInRevoke()">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
            } else if(record=="3" ){//迁出审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toCheckHjqc()">&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
            } else if(record=="7" ){//迁入审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toCheckHjqr()">&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
            } else if(record=="6" ){//迁入审批通过查看
                s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toCheckSuccessHjqr()">&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
            }
        } else {
            if (record == "2") {
                s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toApplyIn()">&nbsp;&nbsp;申请&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "5") {
                s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toRevoke(4)">&nbsp;&nbsp;撤回&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "4") {
                s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toEditInRevoke()">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "3") {//迁出审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqc()">&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "7") {//迁入审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqr()">&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }else if (record == "6") {//迁入审批通过查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()">&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }
        }
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()">&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
        // 司法局用户
    } else if (level == '8') {
        // 山西个性化需求
        if(localCode == "140000") {
            if(record=="2"){
                s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="toInShenhe()"  >&nbsp;&nbsp;迁入审批&nbsp;&nbsp;</a>&nbsp';
            }else if(record=="3" ){//迁出审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqc()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }else if(record=="7" ){//迁入审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }else if(record=="6" ){//迁入审批通过查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }
        } else {
            if (record == "5") {
                s += '&nbsp;<a class="mini-button mini-button-warning"  onclick="toInShenhe()"  >&nbsp;&nbsp;迁入审批&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "3") {//迁出审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqc()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "7") {//迁入审批失败查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "2") {//迁出审批通过查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            } else if (record == "6") {//迁入审批通过查看
                s += '&nbsp;<a class="mini-button mini-button-success"  onclick="toCheckSuccessHjqr()"  >&nbsp;&nbsp;迁移详情&nbsp;&nbsp;</a>&nbsp';
            }
        }
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    } else if (level == '6' || level == '7') {
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="toViewHjqc()"  >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    }
}

//户籍迁出审核
function toOutShenhe() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqc/toOutShenhe/view?priNum=" + row.priNum,
        title: "户籍迁出审核",
        width: "40%",
        height: "60%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//户籍迁出--迁移办理
function toQybl() {
    mini.open({
        //targetWindow: window,
        url: "/azbj/bjdxInfo/hjqr/addPrisonerMvOut/view",
        title: "户籍迁移办理",
        width: 720,
        height: 720,
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            // 点击保存成功
            if (action == "ok"){
                grid.reload();
            }else {
                //点击取消/×号
                var iframe = this.getIFrameEl();
                //获取选中、编辑的结果
                var data = iframe.contentWindow.GetData();
                var taskId = data.taskId;
                var priNum = data.priNum;
                var id = data.id
                $.ajax({
                    url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId,
                    type: 'get',
                    success: function (success) {
                    }
                })
                grid.reload();
            }
        }
    });
}

//司法所撤回
function toRevoke(state) {
    var row = grid.getSelected();
    mini.confirm("确定撤回该条数据吗？",
        "确定？",
        function (action) {
            if (action == "ok") {
                $.ajax({
                    url: "/azbj/bjdxInfo/hjqc/toRevoke?id=" + row.id + "&state=" + state,
                    type: "post",
                    success: function (success) {
                        if (success.code == 1) {
                            mini.alert("撤回成功");
                            grid.reload();
                        } else if (success.code == 5599) {
                            mini.alert(success.message);
                        } else {
                            mini.alert("撤回失败");
                        }
                    }
                });
            }
        });
}

//司法所迁出撤回--编辑
function toEditOutRevoke() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/addPrisonerMvOut/view?id=" + row.id,
        title: "再次发起迁移",
        width: 650,
        height: 580,
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}


//迁入申请
function toApplyIn() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/addPrisonerMvIn/view?id=" + row.id,
        title: "户籍迁移办理",
        width: "40%",
        height: "65%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//司法所迁入撤回--编辑
function toEditInRevoke() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/addPrisonerMvIn/view?id=" + row.id,
        title: "编辑",
        width: "45%",
        height: "80%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}
//司法局迁入审批
function toInShenhe() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/toInShenhe/view?priNum=" + row.priNum,
        title: "户籍迁入审核",
        width: "40%",
        height: "65%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//档案信息
function toViewHjqc() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqc/toViewTabs/view?priNum=" + row.priNum,
        title: "查看",
        width: "60%",
        height: "80%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//迁出审批失败查看
function toCheckHjqc() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqc/toOutShenhe/check?id=" + row.id,
        title: "查看",
        width: "40%",
        height: "40%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//迁入审批失败查看
function toCheckHjqr() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/toInShenhe/check?id=" + row.id,
        title: "查看",
        width: "40%",
        height: "40%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//迁入审批成功查看
function toCheckSuccessHjqr() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/toInShenhe/checkSuccess?id=" + row.id,
        title: "查看",
        width: "40%",
        height: "40%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}

//迁入地司法所接收按钮
function toAccept() {
    var row = grid.getSelected();
    mini.open({
        url: "/azbj/bjdxInfo/hjqr/toAccept/view?priNum="+row.priNum,
        title: "户籍迁入接收",
        width: "40%",
        height: "65%",
        allowDrag: true,
        allowResize: false,
        showCloseButton: true,
        onload: function () {
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}